<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="/common/meta.jsp"></jsp:include>
<jsp:include page="/common/css_js.jsp"></jsp:include>
<sx:head />
<script>
$(document).ready(
		function() {
			$("#loginName").focus();
			$("#inputForm").validate({
								rules : {
									loginName : {
										required : true,
										stringCheck : true,
										maxlength : 22 ,
										remote : {
											url:"user!checkLoginName.action",
											type: "POST",
											data: {                                
												loginName: function () {    
													var loginName =$("#loginName").val();
													return encodeURIComponent(loginName);                                
												},
												oldLoginName:function () { 
													return encodeURIComponent('${loginName}');
												}
											}  
										}
									},
									password : {
										stringCheck : true,
										required : true,
										minlength : 3,
										maxlength : 255 
									},
									passwordConfirm  : {
										equalTo : "#password"
									}
								},
								messages : {
									loginName : {
										required : "用户名不能为空",
										stringCheck : "用户名不能有特殊字符", 
										maxlength : "最多为22位",
										remote : "用户登录名已存在"
									},
									password : {
										stringCheck : "密码不能有特殊字符",
										required : "密码不能为空",
										minlength : "长度不正确",
										maxlength : "最多为255位"
									},
									passwordConfirm  : {
										equalTo : "输入与上面相同的密码"
									}
								}
						});
		});
	
</script>
</head>

<body>
	<s:if test="id == null">
		<jsp:include page="/common/content_top.jsp"><jsp:param name="title" value="新增用户"/></jsp:include>
	</s:if>
	<s:else>
		<jsp:include page="/common/content_top.jsp"><jsp:param name="title" value="修改用户"/></jsp:include>
	</s:else>
	<br/>
	<form id="inputForm" action="user!save.action" method="post">
		<input type="hidden" name="id" value="${id}" />
		<table border="0" style="margin-left: 30px;">
			<tr>
				<td align="right">登录名:</td>
				<td><input type="text" name="loginName" size="40"
					id="loginName" value="${loginName}" />
				</td>
			</tr>			
			<tr>
				<td align="right">密码:</td>
				<td><input type="password" id="password" name="password"
					size="40" value="" />
				</td>
			</tr>
			<tr>
				<td align="right">确认密码:</td>
				<td><input type="password" id="passwordConfirm"
					name="passwordConfirm" size="40" value="" /></td>
			</tr>
			<tr>
				<td align="right">生效时间:</td>
				<td><sx:datetimepicker displayFormat="yyy-MM-dd"  name="effectiveTime" value="%{effectiveTime}"/></td>
			</tr>
			<tr>
				<td align="right">过期时间:</td>
				<td><sx:datetimepicker displayFormat="yyy-MM-dd"  name="expiredTime" value="%{expiredTime}"/></td>
			</tr>
			
			
			
			<tr>
				<td align="right">角色:</td>
				<td><s:checkboxlist name="checkedRoleIds" list="allRoleList"
						listKey="id" listValue="name" theme="custom" /></td>
			</tr>
			<tr>
				<td colspan="2" align="center"><security:authorize ifAnyGranted="user_update">
						<input class="button" type="submit" value="提交" />&nbsp;
					</security:authorize> <input class="button" type="button" value="返回"
					onclick="history.back()" /></td>
			</tr>
		</table>
	</form>
<jsp:include page="/common/content_bottom.jsp"/>
</body>
</html>
